<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../react18/react.development.js"></script>
    <script src="../react18/react-dom.development.js"></script>
    <script src="../react18/babel.min.js"></script>
  </head>
  <body>
    <button id="btn">点击切换娱乐新闻</button>
    <div id="app"></div>
    <script type="text/babel">
      const oBtn = document.getElementById("btn");
      //定义一个数据代表当前App组件内的标题
      let appTitle = "今日天气预报";

      //点击按钮的时候,改变数据,观察虚拟DOM是否重新渲染
      //发现视图没有重新创建虚拟DOM并重新渲染
      //其实就是没有响应式(数据改变--->视图更新)
      oBtn.onclick = function () {
        appTitle = "今日娱乐新闻";
      };

      class App extends React.Component {
        render() {
          return (
            <div>
              <h1>title:{appTitle}</h1>
              <p>content</p>
            </div>
          );
        }
      }

      ReactDOM.createRoot(document.getElementById("app")).render(<App />);
    </script>
  </body>
</html>
